home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Graphics Programming (2nd Edition) / Visual Basic Graphics Programming 2nd Edition.iso / Src / Ch2 / Poly.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-04-05  |  10.2 KB  |  288 lines

  1. VERSION 5.00
  2. Begin VB.Form frmPoly 
  3.    Caption         =   "Poly"
  4.    ClientHeight    =   4095
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   4950
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   4095
  10.    ScaleWidth      =   4950
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.PictureBox picPolyPolygon 
  13.       AutoRedraw      =   -1  'True
  14.       Height          =   1695
  15.       Left            =   2520
  16.       ScaleHeight     =   1635
  17.       ScaleWidth      =   2355
  18.       TabIndex        =   3
  19.       Top             =   2400
  20.       Width           =   2415
  21.    End
  22.    Begin VB.PictureBox picPolyPolyline 
  23.       AutoRedraw      =   -1  'True
  24.       Height          =   1695
  25.       Left            =   0
  26.       ScaleHeight     =   1635
  27.       ScaleWidth      =   2355
  28.       TabIndex        =   2
  29.       Top             =   2400
  30.       Width           =   2415
  31.    End
  32.    Begin VB.PictureBox picPolygon 
  33.       AutoRedraw      =   -1  'True
  34.       Height          =   1695
  35.       Left            =   2520
  36.       ScaleHeight     =   1635
  37.       ScaleWidth      =   2355
  38.       TabIndex        =   1
  39.       Top             =   240
  40.       Width           =   2415
  41.    End
  42.    Begin VB.PictureBox picPolyline 
  43.       AutoRedraw      =   -1  'True
  44.       Height          =   1695
  45.       Left            =   0
  46.       ScaleHeight     =   1635
  47.       ScaleWidth      =   2355
  48.       TabIndex        =   0
  49.       Top             =   240
  50.       Width           =   2415
  51.    End
  52.    Begin VB.Label Label1 
  53.       Alignment       =   2  'Center
  54.       Caption         =   "PolyPolygon"
  55.       Height          =   255
  56.       Index           =   3
  57.       Left            =   2520
  58.       TabIndex        =   7
  59.       Top             =   2160
  60.       Width           =   2415
  61.    End
  62.    Begin VB.Label Label1 
  63.       Alignment       =   2  'Center
  64.       Caption         =   "PolyPolyline"
  65.       Height          =   255
  66.       Index           =   2
  67.       Left            =   0
  68.       TabIndex        =   6
  69.       Top             =   2160
  70.       Width           =   2415
  71.    End
  72.    Begin VB.Label Label1 
  73.       Alignment       =   2  'Center
  74.       Caption         =   "Polygon"
  75.       Height          =   255
  76.       Index           =   1
  77.       Left            =   2520
  78.       TabIndex        =   5
  79.       Top             =   0
  80.       Width           =   2415
  81.    End
  82.    Begin VB.Label Label1 
  83.       Alignment       =   2  'Center
  84.       Caption         =   "Polyline"
  85.       Height          =   255
  86.       Index           =   0
  87.       Left            =   0
  88.       TabIndex        =   4
  89.       Top             =   0
  90.       Width           =   2415
  91.    End
  92. Attribute VB_Name = "frmPoly"
  93. Attribute VB_GlobalNameSpace = False
  94. Attribute VB_Creatable = False
  95. Attribute VB_PredeclaredId = True
  96. Attribute VB_Exposed = False
  97. Option Explicit
  98. Private Type POINTAPI
  99.     X As Long
  100.     Y As Long
  101. End Type
  102. Private Declare Function Polyline Lib "gdi32" (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long
  103. Private Declare Function Polygon Lib "gdi32" (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long
  104. Private Declare Function PolyPolyline Lib "gdi32" (ByVal hdc As Long, lppt As POINTAPI, lpdwPolyPoints As Long, ByVal cCount As Long) As Long
  105. Private Declare Function PolyPolygon Lib "gdi32" (ByVal hdc As Long, lpPoint As POINTAPI, lpPolyCounts As Long, ByVal nCount As Long) As Long
  106. Private Sub Form_Load()
  107. Dim pt(1 To 100) As POINTAPI
  108. Dim counts(1 To 10) As Long
  109. Dim i As Integer
  110. Dim j As Integer
  111. Dim start_i As Integer
  112.     picPolygon.FillStyle = vbDiagonalCross
  113.     picPolyPolygon.FillStyle = vbDiagonalCross
  114.     ' ---------------
  115.     ' Draw a polyline
  116.     ' ---------------
  117.     i = 1
  118.     pt(i).X = 96:    pt(i).Y = 60:    i = i + 1
  119.     pt(i).X = 84:    pt(i).Y = 71:    i = i + 1
  120.     pt(i).X = 66:    pt(i).Y = 71:    i = i + 1
  121.     pt(i).X = 60:    pt(i).Y = 48:    i = i + 1
  122.     pt(i).X = 82:    pt(i).Y = 35:    i = i + 1
  123.     pt(i).X = 112:    pt(i).Y = 42:    i = i + 1
  124.     pt(i).X = 114:    pt(i).Y = 63:    i = i + 1
  125.     pt(i).X = 106:    pt(i).Y = 78:    i = i + 1
  126.     pt(i).X = 85:    pt(i).Y = 86:    i = i + 1
  127.     pt(i).X = 51:    pt(i).Y = 86:    i = i + 1
  128.     pt(i).X = 36:    pt(i).Y = 64:    i = i + 1
  129.     pt(i).X = 44:    pt(i).Y = 35:    i = i + 1
  130.     pt(i).X = 70:    pt(i).Y = 17:    i = i + 1
  131.     pt(i).X = 108:    pt(i).Y = 17:    i = i + 1
  132.     pt(i).X = 126:    pt(i).Y = 32:    i = i + 1
  133.     pt(i).X = 139:    pt(i).Y = 60:    i = i + 1
  134.     pt(i).X = 134:    pt(i).Y = 87:    i = i + 1
  135.     pt(i).X = 115:    pt(i).Y = 99:    i = i + 1
  136.     pt(i).X = 86:    pt(i).Y = 104:    i = i + 1
  137.     pt(i).X = 40:    pt(i).Y = 102:    i = i + 1
  138.     pt(i).X = 19:    pt(i).Y = 79:    i = i + 1
  139.     pt(i).X = 13:    pt(i).Y = 46:    i = i + 1
  140.     pt(i).X = 25:    pt(i).Y = 16:    i = i + 1
  141.     Polyline picPolyline.hdc, pt(1), i - 1
  142.     ' --------------
  143.     ' Draw a polygon
  144.     ' --------------
  145.     i = 1
  146.     pt(i).X = 66:    pt(i).Y = 20:    i = i + 1
  147.     pt(i).X = 53:    pt(i).Y = 50:    i = i + 1
  148.     pt(i).X = 110:   pt(i).Y = 52:    i = i + 1
  149.     pt(i).X = 105:   pt(i).Y = 22:    i = i + 1
  150.     pt(i).X = 144:   pt(i).Y = 26:    i = i + 1
  151.     pt(i).X = 123:   pt(i).Y = 81:    i = i + 1
  152.     pt(i).X = 38:    pt(i).Y = 83:    i = i + 1
  153.     pt(i).X = 11:    pt(i).Y = 13:    i = i + 1
  154.     Polygon picPolygon.hdc, pt(1), i - 1
  155.     ' ------------------
  156.     ' Draw a PolyPolygon
  157.     ' ------------------
  158.     j = 1
  159.     i = 1
  160.     ' Polygon 1.
  161.     start_i = i
  162.     pt(i).X = 15:    pt(i).Y = 33:    i = i + 1
  163.     pt(i).X = 21:    pt(i).Y = 47:    i = i + 1
  164.     pt(i).X = 51:    pt(i).Y = 48:    i = i + 1
  165.     pt(i).X = 64:    pt(i).Y = 19:    i = i + 1
  166.     pt(i).X = 46:    pt(i).Y = 7:     i = i + 1
  167.     counts(j) = i - start_i
  168.     j = j + 1
  169.     ' Polygon 2.
  170.     start_i = i
  171.     pt(i).X = 80:    pt(i).Y = 29:   i = i + 1
  172.     pt(i).X = 75:    pt(i).Y = 17:   i = i + 1
  173.     pt(i).X = 95:    pt(i).Y = 6:    i = i + 1
  174.     pt(i).X = 144:   pt(i).Y = 11:   i = i + 1
  175.     pt(i).X = 152:   pt(i).Y = 82:   i = i + 1
  176.     pt(i).X = 138:   pt(i).Y = 100:  i = i + 1
  177.     pt(i).X = 63:    pt(i).Y = 103:  i = i + 1
  178.     pt(i).X = 49:    pt(i).Y = 91:   i = i + 1
  179.     pt(i).X = 59:    pt(i).Y = 80:   i = i + 1
  180.     pt(i).X = 72:    pt(i).Y = 88:   i = i + 1
  181.     pt(i).X = 127:   pt(i).Y = 84:   i = i + 1
  182.     pt(i).X = 139:   pt(i).Y = 72:   i = i + 1
  183.     pt(i).X = 131:   pt(i).Y = 20:   i = i + 1
  184.     pt(i).X = 101:   pt(i).Y = 16:   i = i + 1
  185.     counts(j) = i - start_i
  186.     j = j + 1
  187.     ' Polygon 3.
  188.     start_i = i
  189.     pt(i).X = 36:    pt(i).Y = 93:    i = i + 1
  190.     pt(i).X = 23:    pt(i).Y = 103:   i = i + 1
  191.     pt(i).X = 7:     pt(i).Y = 92:    i = i + 1
  192.     pt(i).X = 9:     pt(i).Y = 72:    i = i + 1
  193.     pt(i).X = 32:    pt(i).Y = 57:    i = i + 1
  194.     pt(i).X = 78:    pt(i).Y = 57:    i = i + 1
  195.     pt(i).X = 103:   pt(i).Y = 49:    i = i + 1
  196.     pt(i).X = 102:   pt(i).Y = 37:    i = i + 1
  197.     pt(i).X = 108:   pt(i).Y = 28:    i = i + 1
  198.     pt(i).X = 121:   pt(i).Y = 28:    i = i + 1
  199.     pt(i).X = 128:   pt(i).Y = 42:    i = i + 1
  200.     pt(i).X = 126:   pt(i).Y = 58:    i = i + 1
  201.     pt(i).X = 110:   pt(i).Y = 66:    i = i + 1
  202.     pt(i).X = 86:    pt(i).Y = 70:    i = i + 1
  203.     pt(i).X = 43:    pt(i).Y = 70:    i = i + 1
  204.     counts(j) = i - start_i
  205.     j = j + 1
  206.     ' Draw the PolyPolygon.
  207.     PolyPolygon picPolyPolygon.hdc, _
  208.         pt(1), counts(1), j - 1
  209.     ' -------------------
  210.     ' Draw a PolyPolyline
  211.     ' -------------------
  212.     j = 1
  213.     i = 1
  214.     ' Polyline 1.
  215.     start_i = i
  216.     pt(i).X = 14:    pt(i).Y = 31:    i = i + 1
  217.     pt(i).X = 26:    pt(i).Y = 42:    i = i + 1
  218.     pt(i).X = 16:    pt(i).Y = 58:    i = i + 1
  219.     pt(i).X = 29:    pt(i).Y = 73:    i = i + 1
  220.     pt(i).X = 19:    pt(i).Y = 96:    i = i + 1
  221.     counts(j) = i - start_i
  222.     j = j + 1
  223.     ' Polyline 2.
  224.     start_i = i
  225.     pt(i).X = 34:    pt(i).Y = 28:    i = i + 1
  226.     pt(i).X = 51:    pt(i).Y = 40:    i = i + 1
  227.     pt(i).X = 39:    pt(i).Y = 56:    i = i + 1
  228.     pt(i).X = 52:    pt(i).Y = 75:    i = i + 1
  229.     pt(i).X = 43:    pt(i).Y = 93:    i = i + 1
  230.     counts(j) = i - start_i
  231.     j = j + 1
  232.     ' Polyline 3.
  233.     start_i = i
  234.     pt(i).X = 50:    pt(i).Y = 26:    i = i + 1
  235.     pt(i).X = 74:    pt(i).Y = 40:    i = i + 1
  236.     pt(i).X = 59:    pt(i).Y = 55:    i = i + 1
  237.     pt(i).X = 68:    pt(i).Y = 73:    i = i + 1
  238.     pt(i).X = 60:    pt(i).Y = 98:    i = i + 1
  239.     counts(j) = i - start_i
  240.     j = j + 1
  241.     ' Polyline 4.
  242.     start_i = i
  243.     pt(i).X = 71:    pt(i).Y = 24:    i = i + 1
  244.     pt(i).X = 82:    pt(i).Y = 42:    i = i + 1
  245.     pt(i).X = 74:    pt(i).Y = 60:    i = i + 1
  246.     pt(i).X = 81:    pt(i).Y = 78:    i = i + 1
  247.     pt(i).X = 72:    pt(i).Y = 97:    i = i + 1
  248.     counts(j) = i - start_i
  249.     j = j + 1
  250.     ' Polyline 5.
  251.     start_i = i
  252.     pt(i).X = 87:    pt(i).Y = 25:    i = i + 1
  253.     pt(i).X = 99:    pt(i).Y = 41:    i = i + 1
  254.     pt(i).X = 93:    pt(i).Y = 56:    i = i + 1
  255.     pt(i).X = 98:    pt(i).Y = 75:    i = i + 1
  256.     pt(i).X = 87:    pt(i).Y = 95:    i = i + 1
  257.     counts(j) = i - start_i
  258.     j = j + 1
  259.     ' Polyline 6.
  260.     start_i = i
  261.     pt(i).X = 101:    pt(i).Y = 25:    i = i + 1
  262.     pt(i).X = 112:    pt(i).Y = 42:    i = i + 1
  263.     pt(i).X = 104:    pt(i).Y = 58:    i = i + 1
  264.     pt(i).X = 108:    pt(i).Y = 77:    i = i + 1
  265.     pt(i).X = 100:    pt(i).Y = 97:    i = i + 1
  266.     counts(j) = i - start_i
  267.     j = j + 1
  268.     ' Polyline 7.
  269.     start_i = i
  270.     pt(i).X = 115:    pt(i).Y = 24:    i = i + 1
  271.     pt(i).X = 125:    pt(i).Y = 44:    i = i + 1
  272.     pt(i).X = 118:    pt(i).Y = 59:    i = i + 1
  273.     pt(i).X = 123:    pt(i).Y = 81:    i = i + 1
  274.     pt(i).X = 114:    pt(i).Y = 95:    i = i + 1
  275.     counts(j) = i - start_i
  276.     j = j + 1
  277.     ' Polyline 8.
  278.     start_i = i
  279.     pt(i).X = 127:    pt(i).Y = 25:    i = i + 1
  280.     pt(i).X = 142:    pt(i).Y = 43:    i = i + 1
  281.     pt(i).X = 131:    pt(i).Y = 58:    i = i + 1
  282.     pt(i).X = 133:    pt(i).Y = 77:    i = i + 1
  283.     pt(i).X = 126:    pt(i).Y = 94:    i = i + 1
  284.     ' Draw the PolyPolyline.
  285.     PolyPolyline picPolyPolyline.hdc, _
  286.         pt(1), counts(1), j - 1
  287. End Sub
  288.